﻿Public Class Ping
    Public Shared Function Ping(ByVal instring As String)
        Try
            Ping = False
            Dim objPing, objRetStatus
            objPing =
                GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery(
                    "select * from Win32_PingStatus where address = '" & instring & "'")
            For Each objRetStatus In objPing
                If objRetStatus.StatusCode <> 0 Then
                    Ping = False
                Else
                    Ping = True
                End If
            Next
        Catch
            Ping = False
        End Try
    End Function
End Class
